import re
from typing import Dict


class Hero(Dict):
    def __init__(self, info_str) -> None:
        self.info = info_str
        self["干员代号"] = self.__match(r"(?<=\|)干员代号=(.*?)(?=\n)")
        self["阻挡数"] = self.__match(r"(?<=\|)阻挡数=(.*?)(?=\n)")
        self["部署费用"] = self.__match(r"(?<=\|)部署费用=(.*?)(?=\n)")
        self["攻击间隔"] = self.__match(r"(?<=\|)攻击速度=(.*?)(?=\n)")
        self["再部署时间"] = self.__match(r"(?<=\|)再部署=(.*?)(?=\n)")
        self["完美部署费用"] = self.__match(r"(?<=\|)完美部署费用=(.*?)(?=\n)")
        self["初始生命"] = self.__match(r"(?<=\|)初始生命=(.*?)(?=\n)")
        self["初始攻击"] = self.__match(r"(?<=\|)初始攻击=(.*?)(?=\n)")
        self["初始防御"] = self.__match(r"(?<=\|)初始防御=(.*?)(?=\n)")
        self["初始法抗"] = self.__match(r"(?<=\|)初始法抗=(.*?)(?=\n)")
        self["初始生命max"] = self.__match(r"(?<=\|)初始生命max=(.*?)(?=\n)")
        self["初始攻击max"] = self.__match(r"(?<=\|)初始攻击max=(.*?)(?=\n)")
        self["初始防御max"] = self.__match(r"(?<=\|)初始防御max=(.*?)(?=\n)")
        self["初始法抗max"] = self.__match(r"(?<=\|)初始法抗max=(.*?)(?=\n)")
        self["精1生命max"] = self.__match(r"(?<=\|)精1生命max=(.*?)(?=\n)")
        self["精1攻击max"] = self.__match(r"(?<=\|)精1攻击max=(.*?)(?=\n)")
        self["精1防御max"] = self.__match(r"(?<=\|)精1防御max=(.*?)(?=\n)")
        self["精1法抗max"] = self.__match(r"(?<=\|)精1法抗max=(.*?)(?=\n)")
        self["精2生命max"] = self.__match(r"(?<=\|)精2生命max=(.*?)(?=\n)")
        self["精2攻击max"] = self.__match(r"(?<=\|)精2攻击max=(.*?)(?=\n)")
        self["精2防御max"] = self.__match(r"(?<=\|)精2防御max=(.*?)(?=\n)")
        self["精2法抗max"] = self.__match(r"(?<=\|)精2法抗max=(.*?)(?=\n)")
        self["信赖生命"] = self.__match(r"(?<=\|)信赖生命=(.*?)(?=\n)")
        self["信赖攻击"] = self.__match(r"(?<=\|)信赖攻击=(.*?)(?=\n)")
        self["信赖防御"] = self.__match(r"(?<=\|)信赖防御=(.*?)(?=\n)")
        self["信赖法抗"] = self.__match(r"(?<=\|)信赖法抗=(.*?)(?=\n)")

    def __match(self, format):
        value = re.search(format, self.info, re.MULTILINE)
        return value.group(1) if value else ""
